/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mx.its.dd2.Dao;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import mx.its.dds2.modelo.User;
import mx.its.dds2.modelo.User;

/**
 *
 * @author Piter
 */
@Stateless
public class UserDao extends AbstractDao<User> implements UserDaoLocal {
    @PersistenceContext(unitName = "Farmacia-ejbPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public UserDao() {
        super(User.class);
    }
     public boolean findDuplicity(User user){
     Query q = em.createNamedQuery("User.findByDuplicity");
     q.setParameter("nombre", user.getName());
     //q.setParameter("apellidoMaterno", user.());
     //q.setParameter("apellidoPaterno", user.getApellidoPaterno());
     return !q.getResultList().isEmpty();
 } 
    
}
